package com.javaeedev.junit;

import java.util.Vector;

import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

/**
 * Stateful SessionBean
 */
public class CartBean implements SessionBean {

    String customerId;
    Vector contents;

    public void ejbCreate(String customerId) throws CreateException {
        if (customerId == null) {
            throw new CreateException("Null customerId not allowed.");
        }
        else {
            this.customerId = customerId;
        }
        contents = new Vector();
    }

    public void addBook(String title) {
        contents.addElement(title);
    }

    public void removeBook(String title) {
        contents.removeElement(title);
    }

    public Vector getContents() {
        return contents;
    }

    public CartBean() {}

    public void ejbRemove() {}

    public void ejbActivate() {}

    public void ejbPassivate() {}

    public void setSessionContext(SessionContext sc) {}

}
